﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Reviewer.Entities;
using Reviewer.Entities.Services;
using Reviewer.Business;

public partial class CMSV2_Controls_Game_GameFactsheet : System.Web.UI.UserControl
{
    public Guid GameId { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void LoadData()
    {
        using (IGameService service = ServiceFactory.GameService)
        {
            GameFactsheet sheet = service.GetFactsheet(this.GameId);
            if (sheet != null)
            {
                this.uiHtFacsheet.Content = sheet.Data;
            }
        }
    }

    protected void uiBtnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            using (IGameAdminService service = ServiceFactory.GameAdminService)
            {
                GameFactsheet factsheet = new GameFactsheet();
                factsheet.GameId = this.GameId;
                factsheet.Data = this.uiHtFacsheet.Content;
                factsheet = service.SetFactsheet(factsheet);
                if (factsheet != null)
                {
                    this.uiHtFacsheet.Content = factsheet.Data;
                }
            }
        }
    }
}